package com.antt.cn.test2.uis.base;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by baichuan on 2017/4/10.
 */

public abstract class BaseActivity extends AppCompatActivity implements BaseInterface {

    protected static String TAG = "";


    public BaseActivity() {
        super();
        TAG = this.getClass().getName();
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(getLayoutId());

        initView();
        initData();
        initListener();
    }

    /**
     * 处理沉浸式状态栏
     */
    public void status() {
        //透明状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getWindow();
            // Translucent status bar
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    }

    public abstract int getLayoutId();


    public void goTo(Class<? extends AppCompatActivity> activity) {
        if (activity == null)
            return;
        startActivity(new Intent(this, activity));
    }


}
